package cn.javase.concurrent._并发编程._05_共享模型之内存._可见性;

import static java.lang.Thread.sleep;

public class _退不出来的循环 {
    static boolean run = true;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            int a = 0;
            while(run){
                // ....
                if (a == 0) {
                    System.out.println("进入循环");
                }
                a = 1;
            }
        });
        t.start();

        sleep(1);
        run = false; // 线程t不会如预想的停下来
    }
}
